<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <h1></h1>
  <script>
    // 定时器有两种
    // setTimeout 一次性
    // setInterval 重复性

    // 1秒钟后弹出 弹出后就不会再弹了
    // setTimeout(() => {
    //   console.log("今天是元宵节,")
    // }, 1000)

    // let count = 0
    // let timer = setInterval(() => {
    //   if (count == 10) {
    //     clearInterval(timer);
    //   }
    //   console.log(`今天是元宵节${++count}`)
    // }, 1000)



    let h1 = document.querySelector("h1");
    let second = setInterval(() => {
      let date = new Date();
      h1.innerText = `${date.getFullYear()}年${date.getMonth()}月${date.getDate()}日.${date.getHours()}:${date.getMinutes()}:${date.getSeconds()}`
    }, 1000)







  </script>
</body>

</html>